home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / normix21.zip / NORMIX21 / NORMIX.DOC < prev    next >
Text File  |  1995-01-10  |  24KB  |  419 lines

  1.                PC-NORMIX (Version 2.1)
  2.            Copyright (C) John H. Wolfe, 1995. All rights reserved.
  3.  .......................................................................
  4.     A.  Identification
  5.        1. Title= Cluster and pattern analysis of normal mixtures
  6.        2. Identification= G7 PC-NORMIX (Version 2.1)
  7.        3. Category= Multivariate Statistics
  8.        4. Compiler/Operating System= The source code has been tested on 
  9.           four different computer/compiler/operating system combinations and
  10.           works on all four with little or no modification.
  11.           Computer:         Compiler:                   Operating System:
  12.           ----------        --------------------        -----------------
  13.           80286             Microsoft Fortran 5.0       MSDOS
  14.           80386/80486       Microsoft PowerStation      MSDOS Extended
  15.           VAX 11/780        f77                         unix
  16.           IBM 4381          FORTVS                      CMS
  17.  
  18.        5. Date= January 1995
  19.        6. Programmer= John H. Wolfe
  20.     B.  Purpose
  21.         This program is a tool for the user seeking maximum likelihood 
  22.         estimates of the parameters of a mixture of multivariate normal 
  23.         distributions. The program solves the equations for maximum likelihood,
  24.         using an iterative algorithm. Because mixture problems usually have
  25.         multiple relative maxima, the program will produce different results,
  26.         depending on the initial estimates supplied by the user. One should
  27.         run a variety of other clustering programs first, and then use their
  28.         results as initial estimates for NORMIX. This procedure has two primary
  29.         benefits: 
  30.            1. It will evaluate different solutions produced by other clustering 
  31.               programs by computing their likelihood.
  32.            2. Given a solution from another clustering program, it will proceed
  33.               to generate a "better" solution with greater likelihood.
  34.  
  35.            If the user does not input his own initial estimates, a default 
  36.         hierarchical grouping procedure will generate initial estimates 
  37.         for the iterative algorithm.  It is not recommended that the user 
  38.         rely solely on this default option.
  39.            An option permits the user to specify whether the covariance
  40.         matrices within types will be the same or different. The unequal 
  41.         covariance option requires larger sample sizes for reliable results,
  42.         in most cases. Also, the unequal covariance case has many 
  43.         singularities in the likelihood function.  Fortunately, Peters and 
  44.         Walker (1978) showed that almost surely the likelihood function has 
  45.         a unique maximum within a neighborhood of the population parameters 
  46.         of the mixture for sufficiently large N.
  47.             This program estimates more parameters than clustering procedures
  48.         which assume a Euclidean distance. As in multiple regression, the more
  49.         parameters that are estimated, the larger the sample size should be.
  50.         If a common covariance matrix is assumed, a good sample size might
  51.         be 20 times the number of variables. If the clusters have different
  52.         covariance matrices, a good sample size might be 20 times the number
  53.         of clusters times the number of variables.
  54.  
  55.  
  56.           References.
  57.            Wolfe, John H. (1970).
  58.              Pattern clustering by multivariate mixture analysis.
  59.              Multivariate Behavioral Research, 5, 329-350.
  60.            Wolfe, John H. (1978).
  61.              Comparative cluster analysis of patterns of vocational interest.
  62.              Multivariate Behavioral Research, 13, 33-44.
  63.            Peters, B. C. & Walker, H. F. (1978). An iterative procedure for 
  64.              obtaining maximum-likelihood estimates of the parameters for a
  65.              mixture of normal distributions. SIAM J. Appl. Math., 35, 362-378. 
  66.  
  67.     C.  Usage
  68.        1. Storage requirements= variable, depending on the data.
  69.           The requirements are displayed on the screen, prior to execution of
  70.           the analysis. On the UNIX or CMS systems, storage may be increased
  71.           by recompiling the main program (NORMIX.FOR) with larger dimension
  72.           for the A array and the DATA statement that follows DIMENSION A().
  73.           This version uses extended memory, as needed, but large problems
  74.           could fail on computers with small memories.
  75.           
  76.        2. Restrictions=  the number of types must not exceed 20.  There
  77.           are no fixed limits on the number of variables or sample size.
  78.           However, all data and arrays must fit into RAM.
  79.  
  80.        3. Environment= The PC executable file PCNORMIX.EXE requires an 80386
  81.           or higher CPU. 
  82.  
  83.        4. Error messages= Bad initial estimates or diverging iterations
  84.           can cause strange estimates of the parameters- such as
  85.           negative variances or singular correlation matrices which
  86.           result in system diagnostics.
  87.  
  88.        5. Time= Observed run times for the four sample problems accompanying
  89.           this program are given below.            
  90.  
  91.                     SAMPLE PROBLEM CHARACTERISTICS AND RUN TIMES
  92.             Characteristic          Irismap  Irismix   Artificial   SVIB
  93.             ------------------------------------------------------------
  94.             Equal Covariances         Yes      No          No       Yes
  95.             Sample Size               150      150        225       113
  96.             No. of Variables           4        4          2         22
  97.             No. of Types              3-4      3-4        1-4      13-15
  98.             Hypothesis:Iterations    3:27     3:13        2:21     13:3
  99.                                      4:19     4:29        3:27     14:2
  100.                                                          4:28     15:2
  101.             CPU Seconds
  102.             ------------------------------------------------------------
  103.               IBM 4381                 7.3      8.4       12.4       28.5
  104.               VAX 11/780              55.6     56.1       86.0      188.8
  105.               80286 (8 MHz)          795.0   1136.0     1731.0     2860.0
  106.               80286+80287 (8 MHz)    157.0    204.0      297.0      517.0
  107.               80386 (33 MHz)         184.6    279.2      385.3      501.1
  108.               80486DX33                6.9      6.4        9.2       21.2
  109.               80486DX66                3.8      3.5        4.8       11.8
  110.  
  111.  
  112.           On the IBM 360/65, the CPU time in minutes was given by
  113.           the following two formulas:
  114.           Common covariance matrix option:
  115.             Minutes =(1.0e-6)*( 1667*(2*t-7) +m*(2.865*n*v +4.961*m)
  116.                                +4.25*t*v**2     +2.12*t*v**3 +67*n*t
  117.                                +1.23*n*i*t*(v+2)   )       .
  118.           Different covariance matrices option:
  119.             Minutes =(1.0e-6)*( m*(2.865*n*v +4.961*m) +4.25*t*v**2
  120.                                 +67*n*t +0.62*n*i*t*(v+2)  )       .
  121.             where,
  122.               t = number of types +1
  123.               v = number of variables
  124.               i = number of iterations (usually 40-80 )
  125.               m = number of kmeans
  126.               n = sample size
  127.            Time for the 33MHz 486 DX is estimated as 1/25 of the above.
  128.  
  129.        6. Files=
  130.            Logical I/O unit numbers are assigned to files as follows:
  131.            15      Input-Form  statements (filename specified interactively,
  132.                                            default: "thisjob")
  133.            11      Input data (filename specified on Input-Form; if blank,
  134.                               data are read from unit 15 following the format
  135.                               statement on the Input-Form)
  136.            12      Printout of the analysis (filename specified on Input-Form,
  137.                                              default: "prinout")
  138.             3      "kc3temp" Scratch unit containing factor scores
  139.             9      "kv9temp" Scratch unit containing raw data
  140.             4      "discrim" = the discriminant scores
  141.             7      "dumpout"  the parameter estimates if iteration limit is
  142.                               reached. These can be used to continue the
  143.                               analysis by including them as initial estimates
  144.                               on a new Input-Form.
  145.       
  146.  
  147.  
  148.        7. Input
  149.           Input to the program comes from three sources:
  150.              a. Keyboard: one line containing the file name of the Input-Form.
  151.              b. Input-Form file.
  152.              c. Data file (filename as specified on the Input-Form)
  153.           The program prompts the user for the name of the file containing the
  154.           input-form. However, by using the batch program normix.bat, one can
  155.           put the input-form file directly on the command line as the first
  156.           argument. One can also redirect the console output to a script file
  157.           by using an optional second argument. For example the command
  158.                           normix svib script  
  159.           would read the input-form from the file "svib.inp" and redirect the
  160.           console output to the file named "script". For a further example, try
  161.                            examples
  162.           which runs the batch file "examples.bat" to run all of the sample 
  163.           problems supplied with this package. 
  164.  
  165.  
  166.             ***Directions for Filling Out the Input-Form****************
  167.                 The Input-Form is a set of control statements by means of
  168.               which the user specifies the dimensions of the data and
  169.               the options he chooses. The alphabetic contents of the
  170.               Input-Form are ignored by the program, but provide a
  171.               useful guide to the numerical contents. The file "form.inp"
  172.               accompanying this documentation is a blank template with the
  173.               alphabetic contents of the Input-Form printed in. The
  174.               user should copy the template file onto another file and edit 
  175.               it, filling in the appropriate numerical values and other 
  176.               information. Please note that this form does NOT consist of
  177.               key words followed by free-form input, as in SAS or SPSS. The
  178.               parameters must be entered in the exact columns specified.
  179.  
  180.          In the Input-Form layout below, fill in values where zeros are
  181.   ************************************************************************
  182. USER=****                                           DATE USED=24/07/90  01
  183. TITLE=***                                                               02
  184. COMMENTS=                                                               03
  185. COMMENTS=                                                               04
  186. NUMBER OF VARIABLES=00  SAMPLE SIZE=0000                                05
  187. HYPOTHESES FOR NO.  OF TYPES=00,00,00,00,00,00,00,00,00,00,00,00,00,    06
  188. DIFFERENT COVARIANCE MATRIX IN EACH TYPE=0  MINIMUM CLUSTER SIZE=000    07
  189. CONTINUE WITH MORE TYPES IF PROBABILITY OF NULL HYPOTHESIS IS BELOW.000 08
  190. NO.  OF INITIAL KMEANS GENERATED=000  MAXIMUM HIERARCHY PRINTED=000     09
  191. MAXIMUM ITERATIONS=000   PRINT ITERATION=0                              10
  192. DATA INPUT FILE NAME=                                                   11
  193. PRINTOUT FILE NAME=                                                     12
  194. DATA FORMAT= (                                                       )  13
  195. INITIAL ESTIMATES, TYPES=00 MEANS ARE READ=0 STD.DEVS=0 CORRELATIONS=0  14
  196.   ************************************************************************
  197.  
  198.             ********Additional Remarks on the Input-Form****************
  199.  
  200.                 The single-digit zeros in lines 07 and 10 are logical
  201.               variables, i.e., 1 means yes and 0 means no.
  202.               Standard default options are invoked when lines 06 through
  203.               12 are left blank or zero, but this usage is not recommended.
  204.  
  205.                 Lines 1-4 will be printed at the top of each page, and
  206.                 the user should fill them with descriptive comments
  207.                 concerning his particular problem.
  208.  
  209.                 In line 5, col 21-22, enter the number of numeric variables 
  210.                 to be analyzed, not including case IDs, if any.
  211.  
  212.                 In line 6, enter the hypothesized numbers of types in
  213.                 ascending order. If all entries are 00, then 01 ...20
  214.                 will be used.
  215.  
  216.                 In line 7, col. 42, the computer will assume equal
  217.                 covariances unless 1 is entered. If different covariance
  218.                 matrices are to be estimated for each type, then
  219.                 col. 66-68, line 7 specifies the minimum number of points
  220.                 a cluster must have for a covariance matrix to be
  221.                 estimated for it. If its size falls below this minimum,
  222.                 its covariance matrix will be re-initialized to the
  223.                 average within-group matrix.
  224.  
  225.                 In line 8, the program will proceed to a greater number
  226.                 of hypothesized types if the (pseudo-) chi-square test is
  227.                 significant for the likelihood ratio for the current
  228.                 hypothesis/preceding hypothesis. If .999 is entered, the
  229.                 program will ignore this cutoff and continue with the next
  230.                 hypothesis. WARNING: This significance test is known to be
  231.                 incorrect.
  232.  
  233.                 Col. 34-36 in line 9 is the parameter N in subroutine
  234.                 Kmean  and is the size of the sub-sample used to
  235.                 generate initial estimates. The default value
  236.                 is sample size or 2000, whichever is smaller.  If the initial
  237.                 estimates are input by the user, the hierarchical grouping may 
  238.                 shortened by inserting a positive value greater than or equal
  239.                 to 10. (A positive value smaller than 10 will cause the program
  240.                 to hang.) A very useful way to generate a variety of initial
  241.                 estimates is to vary this parameter.
  242.     
  243.                 Col. 65-67 in line 9 specifies the number of hierarchical 
  244.                 initial clusters displayed on the .XXXXX skyline diagram. 
  245.                 The default is 30. Entering 30, or any other number, will
  246.                 produce additional printouts of the first two iterations of
  247.                 the skyline diagrams, and also a printout of the cluster means
  248.                 at each stage of the grouping.
  249.  
  250.                 If line 10, col.20-22 is left blank, the program will
  251.                 iterate until convergence is obtained. This generally
  252.                 takes 50-100 iterations. If 1 is entered in col. 42, 
  253.                 the results of each iteration will be printed.
  254.  
  255.                 Line 11, columns 22-62 is the file name for input. In MS-DOS
  256.                 and Unix, this is the actual file name as it appears in the 
  257.                 directory listing. [On the IBM mainframe CMS, this is
  258.                 a 7-character internal file name which must be related to
  259.                 a corresponding external file name by a CMS FIledef statement 
  260.                 preceding invocation of the program.] 
  261.                 When the filename on this line is left blank, the data input 
  262.                 defaults to the same file as the input form. In this case, the 
  263.                 data immediately follow the format statement on line 13 and 
  264.                 precede line 14 specifying the initial estimates to be read.
  265.                 
  266.                 Line 12, columns 20-60 is the file name for printout. In MS-DOS
  267.                 and Unix, this is the actual file name as it will appear in the 
  268.                 directory listing. [On the IBM mainframe CMS, this is
  269.                 a 7-character internal file name which must be related to
  270.                 a corresponding external file name by a CMS FIledef statement 
  271.                 preceding invocation of the program.] 
  272.                 When the filename is left blank on this line, the printout 
  273.                 defaults to the filename "prinout".
  274.      
  275.                 Line 13 contains a variable format for reading the data. An
  276.                 option allows reading case IDs of up to 24 alphanumeric
  277.                 characters, using a format entry such as A24. A9 would read
  278.                 a nine-character case ID. If a case ID is to be read, it must
  279.                 be the first variable read. For example (t71,a9,t1,3f5.2/2f5.2)
  280.                 would read a nine-character case ID from columns 71-79, then
  281.                 would read three numeric variables from columns 1-15, then two
  282.                 more numeric variables from the next record in columns 1-10.
  283.                 If no case IDs are to be read, the A format is omitted.
  284.  
  285.  
  286.  
  287.   ***IMPORTANT*** Several runs should be done with a variety of initial
  288.                   estimates input starting with line 14. Output from
  289.                   other clustering programs should be used, if available.
  290.                   Also, one should do several runs with different values
  291.                   for the number of KMEANS (line 9, cols 34-36).
  292.  
  293.                 Line 14 follows the data and precedes each set of
  294.                 initial estimates supplied by the user.  In col. 26-27,
  295.                 enter the hypothesized number of types in the set of
  296.                 initial estimates.
  297.                 In columns 44, 55, and 70, enter 1 if initial means are
  298.                 to be read, if initial standard deviations are to be
  299.                 read, and if correlations are to be read, respectively.
  300.  
  301.   *****************Setup for Initial Estimate *********************
  302.          All values are entered in free format in the following order:
  303.          Line 1a   Proportion of population in type 1 
  304.          Line 1b   Means of variables in type 1      
  305.  
  306.          Line 2a   Proportion of population in type 2 
  307.          Line 2b   Means of variables in type 2      
  308.          ...       ...        ...               ...        ...
  309.          ...       ...        ...               ...        ...
  310.          Line ra   Proportion of population in last type  
  311.          Line rb   Means of variables in last type       
  312.  
  313.          Line  c   Standard Deviations within type      
  314.  
  315.          Line  d-1 First row of correlations within type
  316.          Line  d-2 Second row of correlations within type 
  317.          ...       ...        ...               ...        ...
  318.          Line  d-m Last  row of correlations within type 
  319.  
  320.          If the option for different covariance matrices is selected in
  321.          line 7 of the input form, then a set of standard deviations and
  322.          correlation Lines (c-d) follows the means Line for each type.
  323.  
  324.          The complete correlation matrix must be read in, but only the
  325.          upper half is used by the program. Therefore zeros (or any other 
  326.          values) may be used as place-holders in the lower half of the matrix.
  327.  
  328.        8. Output
  329.  
  330.           --Hierarchical Grouping---
  331.                 This routine prints three iterations as follows:
  332.              1) Mahalanobis distances from total covariance matrix.
  333.              2) Mahalanobis distances from within-group covariances
  334.                 of 10 groups found in step 1.
  335.              3) Mahalanobis distances from within-group covariances
  336.                 of 10 groups found in step 2.
  337.  
  338.             Rank= line number of the printout
  339.             Item= individual or object being clustered
  340.             Kmean= the kmean cluster membership of the item
  341.                    the first item of each kmean begins with a - sign.
  342.             Stage= the number of groups remaining after this cluster
  343.                    was merged with the preceding cluster.
  344.             The right hand side of the page is read columnwise. Each
  345.             column represents a stage in the hierarchical grouping.
  346.             Each group begins with a period and continues with an X.
  347.  
  348.  
  349.  
  350.           --Iteration 0 ---
  351.             This printout gives the initial estimates used to begin the
  352.             iterative solution to the likelihood equations. These
  353.             estimates will be the same  as the corresponding
  354.             hierarchical grouping unless the user includes his own
  355.             initial estimates.
  356.  
  357.           --Iteration-last--
  358.             gives the converged solution to the likelihood equations.
  359.  
  360.           --Probabilities of type membership--(self-explanatory)
  361.  
  362.           --Discriminant Functions---
  363.             Gives the weights to apply to the raw scores so that
  364.             discriminant scores will have maximal discrimination between
  365.             groups and the identity matrix for the within-group
  366.             covariances.
  367.  
  368.           --Cluster Members---
  369.             This is a list of case Seq.#s and IDs sorted by cluster.
  370.  
  371.           --Printer Plot---
  372.             Each point has a number or letter designating the type for
  373.             which this individual has the highest probability of
  374.             membership. The first 9 clusters are identified by the
  375.             digits 1-9. The next 11 clusters are identified by the
  376.             letters A-K. An * indicates a place where there are two
  377.             individuals with different cluster membership. Points which
  378.             lie beyond the boundaries of the graph are projected and
  379.             plotted at the boundaries.
  380.  
  381.           --Summary of Likelihood Statistics
  382.             At the end of printout of the last hypothesized number of types
  383.             is a summary page giving the log likelihoods for each hypothesis.
  384.             [After doing 5-6 runs with different initial estimates, I like to
  385.             copy this column into a spreadsheet; one column for each initial
  386.             estimate, then create a new column that is the maximum across all
  387.             initial estimates. Create another column that is the difference 
  388.             between the current maximum and the maximum for the line above.
  389.             (The pseudo chi-square is proportional to this.) I make my final
  390.             decision as to how many clusters there are by plotting these values
  391.             and taking the one that is just above the line where the values
  392.             level off.]
  393.  
  394.           --Notes on Printing and Editing
  395.             The printout assumes a page of 60 lines by 120 characters wide.
  396.             To allow for page numbers and headers, one should use a listing
  397.             program that prints 66 lines by 133 characters. I like to use
  398.             Norton Utilities lp /133 listing program.
  399.             Normix produces voluminous output, which most users will
  400.             want to edit down. Many editors cannot handle long text files.
  401.             Norton Desktop for Windows contains a desktop editor that works
  402.             for long Normix printouts. There are undoubtedly other editors
  403.             that could be used.
  404.  .......................................................................
  405.  
  406.  
  407.     D.  Trouble Reports:
  408.                Results are not guaranteed, and the author assumes no
  409.           liability for any problems the user may experience in using
  410.           this program. However, I would be greatly interested in hearing
  411.           of people's experiences with it. Please report any questions,
  412.           problems, or difficulties to
  413.                 John H. Wolfe          Internet:  wolfe@acm.org          
  414.                 4310 Hill Street       Telephone: (619) 222-5860
  415.                 San Diego, Ca. 92107.                
  416.  
  417.           If this address doesn't work, try the Membership directories for
  418.           the American Statistical Association or the Classification Society.
  419.